package com.train.servlet;

import com.alibaba.fastjson.JSONObject;
import com.train.service.MovieService_4ImpI;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.List;

@WebServlet("/movie4")
public class Movie_4Servlet extends HttpServlet {

    private MovieService_4ImpI movieService4ImpI=new MovieService_4ImpI();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List list = movieService4ImpI.getMovieOrder();
        JSONObject json = new JSONObject();
        if(list.size()!=0){
            json.put("code",200);
            json.put("msg","OK");
            json.put("data",list);
        }else {
            json.put("code",200);
            json.put("msg","OK");
        }

        response.getWriter().write(json.toString());
    }
}
